package fw.qaz.asmx.reader.view;

import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Path;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.TextView;

public class ReadView extends TextView
{
    private Path mPath;
    Bitmap mCurPageBitmap = null;

    public ReadView(Context context)
    {
        super(context);
        init();
    }

    public ReadView(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        init();
    }

    public ReadView(Context context, AttributeSet attrs, int defStyleAttr)
    {
        super(context, attrs, defStyleAttr);
        init();
    }

    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public ReadView(Context context, AttributeSet attrs, int defStyleAttr,
                    int defStyleRes)
    {
        super(context, attrs, defStyleAttr, defStyleRes);
        init();
    }

    private void init()
    {
        mPath = new Path();
    }

    public void setBitmaps(Bitmap bm1)
    {
        mCurPageBitmap = bm1;
    }

    @Override
    protected void onDraw(@NonNull Canvas canvas)
    {
        super.onDraw(canvas);
        //canvas.save();
        //canvas.clipPath(mPath, Region.Op.XOR);
        canvas.drawBitmap(mCurPageBitmap, 0, 20, null);
        //canvas.restore();
    }
}
